//
//  AccountCollectionReusableView.swift
//  ZNHXManagement
//
//  Created by 四川中农 on 2018/9/29.
//  Copyright © 2018年 四川中农. All rights reserved.
//

import UIKit

class AccountCollectionReusableView: UICollectionReusableView {

    @IBOutlet weak var headerImg: UIImageView!
    @IBOutlet weak var shadowView: UIView!
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var addressLabel: UILabel!
    @IBOutlet weak var monthCount: UILabel!
    @IBOutlet weak var lastMonthCount: UILabel!
    @IBOutlet weak var starLabel: UILabel!
    
    var statisticsClosure:BackIntValue! // 0 本月  1 上月
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        self.headerImg.setCornerRadio(radio: 50, isMask: true)
//        self.headerImg.setBorder(color: "#000000", width: 2)
//        self.shadowView.setCornerRadio(radio: 50, isMask: false)
//        self.shadowView.setShadow(color: "#000000,", offset: CGSize.init(width: 0, height: 2), radius: 10, opacity: 0.2)
    }
    
    func reload(withModel model:UserInfoModel? = nil){
        if model != nil {
            self.monthCount.text = model!.nowMonthCount + "单"
            self.lastMonthCount.text = model!.prevMonthCount + "单"
            self.starLabel.text = "我收到的评价：" + (model?.score == "" ? "0.0" : model!.score) + "分"
        }
        self.nameLabel.text = Utils.getUserDefaulsFor(key: "name") as? String
        self.addressLabel.text = Utils.getUserDefaulsFor(key: "address") as? String
        
    }
    
    
    // MARK:本月
    @IBAction func monthButtonClick(_ sender: UIButton) {
        if self.statisticsClosure != nil {
            self.statisticsClosure(0)
        }
    }
    
    // MARK:上月
    @IBAction func lastMonthButtonClick(_ sender: UIButton) {
        if self.statisticsClosure != nil {
            self.statisticsClosure(1)
        }
    }
    
    
}
